<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateQuestionsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('questions', function (Blueprint $table) {
            //题目表
            $table->bigIncrements('id');
            $table->tinyInteger('type')->default(1)->comment('类型1-单选 2-多选 3-判断 4-题帽');
            $table->bigInteger('pid')->default(0)->comment('父id针对题帽题');
            $table->tinyInteger('status')->default(1)->comment('状态1-开启0-关闭');
            /**
             * 单选：我国的根本政治制度是什么
             * 多选：下列属于寡头企业的是
             * 判断：毛泽东思想是有毛泽东创立并提出的
            **/
            $table->mediumText('content')->comment('题目内容');
            /**
             * type对多选和单选有效 1-文字2-图片
             * 单选
             * [
             *  {"key":"1","content":"社会主义制度","type":"1"},
             *  {"key":"2","content":"人民代表大会制度","type":"1"},
             *  {"key":"3","content":"政治协商制度","type":"1"},
             *  {"key":"4","content":"民族区域自治制度","type":"1"}
             * ]
             * 多选
             * [
             *  {"key":"1","content":"某副食品加工厂","type":"1"},
             *  {"key":"2","content":"中石化","type":"1"},
             *  {"key":"3","content":"某软件制造商","type":"1"},
             *  {"key":"4","content":"移动公司","type":"1"},
             *  {"key":"5","content":"国家电网","type":"1"},
             * ]
             * 判断
             * [
             *  {"key":"1","content":"正确"},
             *  {"key":"2","content":"错误"}
             * ]
             * 题帽题选项在子题中
             **/
            $table->mediumText('options')->nullable(true)->comment('选项');
            /**
             * 单选['1']
             * 多选["2","4"]
             * 判断["2"]
             */
            $table->string("keys",255)->nullable(true)->comment("答案");
            $table->mediumText('analysis')->nullable(true)->comment("答案解析,题帽题不用");
            $table->integer('answer_num')->default(0)->comment("参与人数");
            $table->integer('correct_num')->default(0)->comment("正确人数");
            $table->integer("sort")->default(99)->comment("顺序（针对于题帽题的顺序）");
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('questions');
    }
}
